#ifndef LEVELDRIVER_H_
#define LEVELDRIVER_H_

#include "DSP2833x_Device.h"

class LevelDriver
{
public:
	enum Axes { XAxis = 0, YAxis, ZAxis };
	
private:
	float values[3];

	enum Registers
	{
		WhoAmI = 0x0F,
		Offset_X = 0x16,
		Offset_Y = 0x17,
		Offset_Z = 0x18,
		Gain_X = 0x19,
		Gain_Y = 0x1A,
		Gain_Z = 0x1B,
		Ctrl_Reg1 = 0x20,
		Ctrl_Reg2 = 0x21,
		Ctrl_Reg3 = 0x22,
		Status_Reg = 0x27,
		OutX_L = 0x28,
		OutX_H = 0x29,
		OutY_L = 0x2A,
		OutY_H = 0x2B,
		OutZ_L = 0x2C,
		OutZ_H = 0x2D,
		FF_wu_ths_L = 0x34
	};
  
	void WriteData(Registers regaddr, unsigned char data);
	unsigned char ReadData(Registers regaddr);
	void SetupSPI();
	unsigned short WriteWord(unsigned short data);
  
public:
	void Init();
	float ReadAccel(Axes axis);
	void Update();
};

#endif /*LEVELDRIVER_H_*/
